<template>
	<div class="Echart" ref="Echart" >

	</div>
</template>

<script>
	var echarts = require('echarts');
	export default {
		data: function() {
			return {
				myChart: '', //图标对象
			}
		},
		props: ['option'],
		watch:{
		  	option:function() {

			    if(this.option != ''){
			  		if(!this.myChart){
			  			this.setEchart();
			  		} else {
			  			this.myChart.clear();
			  			this.myChart.setOption(this.option);
			  		}
			  	} else {
			  		if(this.myChart){
			  			this.myChart.clear();
			  		}
			  	}
		  	},
		},
		methods: {
			setEchart () {
			    let dom = this.$refs.Echart;
				this.myChart = echarts.init(dom);
				this.myChart.setOption(this.option);
			},
		}
	}
</script>

<style>

</style>